<template>
    <!-- 数据大屏顶部 -->
    <div class="top">
        <div class="left">
            <span class="lbtn" @click="goHome">首页</span>
        </div>
        <div class="center">
            <div class="title">智慧旅游可视化大平台</div>
        </div>
        <div class="right">
            <span class="rbtn">统计报告</span>
            <span class="time">当前时间:{{ time }}</span>
        </div>
    </div>
</template>
<script setup lang='ts' name='top'>
import { useRouter } from 'vue-router';
import moment from 'moment';
import { onBeforeUnmount, onMounted, onUnmounted, ref } from 'vue';
let $router = useRouter()
let time = ref(moment().format('YYYY年MM月DD日 hh:mm:ss'))
let timer = ref(0)
//首页按钮回调
const goHome = () => {
    $router.push('/home')
}
onMounted(() => {
    timer.value = setInterval(() => {
        time.value = moment().format('YYYY年MM月DD日 hh:mm:ss')
    }, 1000)
})
onBeforeUnmount(() => {
    clearInterval(timer.value)
})

</script>


<style scoped lang="scss">
.top {
    width: 100%;
    height: 40px;
    display: flex;

    .left {
        flex: 1.5;
        background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
        background-size: 100% 100%;

        .lbtn {
            width: 100px;
            height: 40px;
            float: right;
            background: url(../../images/dataScreen-header-btn-bg-l.png) no-repeat;
            background-size: cover;
            text-align: center;
            line-height: 40px;
            color: #20fcff;
            font-size: 20px;
        }
    }

    .center {
        flex: 2;

        .title {
            width: 100%;
            height: 74px;
            background: url(../../images/dataScreen-header-center-bg.png) no-repeat;
            background-size: 100% 100%;
            line-height: 74px;
            color: #20fcff;
            font-size: 30px;
            text-align: center;
        }
    }

    .right {
        flex: 1.5;
        background: url(../../images/dataScreen-header-right-bg.png) no-repeat;
        background-size: 100% 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .rbtn {
            width: 150px;
            height: 40px;
            background: url(../../images/dataScreen-header-btn-bg-r.png);
            background-size: 100% 100%;
            float: left;
            text-align: center;
            line-height: 40px;
            color: #20fcff;
        }

        .time {
            color: #20fcff;
            margin-right: 10px;
            font-size: 20px;
        }
    }
}
</style>